package com.wms.system.domain.vo;

import com.wms.common.utils.StringUtils;

/**
 * 路由元信息配置
 */
public class MetaVo {
    /**
     * 设置该路由在侧边栏、面包屑中展示的名字
     */
    private String title;

    /**
     * 路由组件的图标，对应路径src/icons/svg
     */
    private String icon;

    /**
     * 设置该路由是否在侧边栏隐藏
     */
    private boolean noCache;

    /**
     * 外部链接地址（http://、https://）
     */
    private String link;

    public MetaVo() {

    }

    /**
     * 基础配置
     *
     * @param title
     * @param icon
     */
    public MetaVo(String title, String icon) {
        this.title = title;
        this.icon = icon;
    }

    /**
     * 带缓存控制
     *
     * @param title
     * @param icon
     * @param noCache
     */
    public MetaVo(String title, String icon, boolean noCache) {
        this.title = title;
        this.icon = icon;
        this.noCache = noCache;
    }

    /**
     * 带外链
     *
     * @param title
     * @param icon
     * @param link
     */
    public MetaVo(String title, String icon, String link) {
        this.title = title;
        this.icon = icon;
        this.link = link;
    }

    public MetaVo(String title, String icon, boolean noCache, String link) {
        this.title = title;
        this.icon = icon;
        this.noCache = noCache;
//        验证链接协议有效性，避免非法链接注入
        if (StringUtils.ishttp(link)) {
            this.link = link;
        }
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public boolean isNoCache() {
        return noCache;
    }

    public void setNoCache(boolean noCache) {
        this.noCache = noCache;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }
}
